//
//  LHRecommendResTableViewCell.m
//  Knight_Tour
//
//  Created by 庞魁 on 15-5-15.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommendResTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface LHRecommendResTableViewCell ()

@property (nonatomic, retain) UILabel *resName;
@property (nonatomic, retain) UIImageView *resPic;
@property (nonatomic, retain) UIImageView *starPic;
@property (nonatomic, retain) UILabel *resAddress;
@property (nonatomic, retain) UILabel *resRecommendReson;


@end

@implementation LHRecommendResTableViewCell


- (void)dealloc
{
    [_resName release];
    [_resPic release];
    [_starPic release];
    [_resAddress release];
    [_resRecommendReson release];
    [super dealloc];
    
}

// 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.resName = [[UILabel alloc] init];
        
        [self.contentView addSubview:_resName];
        
        [_resName setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17]];
        
        [_resName release];
        
        
        self.resPic = [[UIImageView alloc] init];
        
        self.resPic.layer.cornerRadius = 7;
        self.resPic.clipsToBounds = YES;
        
        [self.contentView addSubview:_resPic];
        
        [_resPic release];
        
        
        self.resAddress = [[UILabel alloc] init];
        
        [self.contentView addSubview:_resAddress];
        
        [_resAddress setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
        
        [_resAddress release];
        
        
        self.starPic = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_starPic];
        
//        _starPic.backgroundColor = [UIColor colorWithRed:0.099 green:0.760 blue:0.974 alpha:1.000];
        
        [_starPic release];
        
        
        self.resRecommendReson = [[UILabel alloc] init];
        
        [self.contentView addSubview:_resRecommendReson];
        
        [_resRecommendReson setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
        
        [_resRecommendReson release];
        
        
        
    }
    
    
    
    
    return self;
}

/**
 *  设置自定义cell的布局信息
 */
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _resPic.frame = CGRectMake(10, 20, self.frame.size.width / 3, self.frame.size.width / 3);
    
    _resName.frame = CGRectMake(_resPic.frame.origin.x + self.frame.size.width / 3 + 20, _resPic.frame.origin.y, 200, 30);
    
    _starPic.frame = CGRectMake(_resPic.frame.origin.x + self.frame.size.width / 3 + 20, _resName.frame.origin.y + self.frame.size.width / 13 - 10, 60, 50);
    
    _resAddress.frame = CGRectMake(_resPic.frame.origin.x + self.frame.size.width / 3 + 20, _starPic.frame.origin.y + self.frame.size.width / 12, 180, 40);
    
    _resRecommendReson.frame = CGRectMake(_resPic.frame.origin.x + self.frame.size.width / 3 + 20, _resAddress.frame.origin.y + self.frame.size.width / 12, 200, 40);
    

    
    
}

/**
 *  重写setter方法
 */
- (void)setRecommendRes:(LHRecommendRestaurantModel *)recommendRes
{
    if (_recommendRes != recommendRes) {
        
        [_recommendRes release];
        
        _recommendRes = [recommendRes retain];
        
    }
    
    _resName.text = recommendRes.name;
    
    [_resPic sd_setImageWithURL:[NSURL URLWithString:recommendRes.cover_s] placeholderImage:[UIImage imageNamed:@"word4"]];
    
    _resAddress.text = recommendRes.address;
    [_resAddress setFont:[UIFont systemFontOfSize:13]];
    _resAddress.numberOfLines = 2;
    
    _resRecommendReson.text = recommendRes.recommended_reason;
    _resRecommendReson.numberOfLines = 3;
    [_resRecommendReson setFont:[UIFont systemFontOfSize:13]];
    
    _starPic.image = [UIImage imageNamed:@"xingji"];
    
}








- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
